package com.jt.service;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.sun.xml.internal.bind.v2.TODO;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class Producer {
    private  static  final  String QUEUE_NAME ="hello-test88";

    /*生产者。。。。。。。简单的连接rabbitmq*/
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory factory=new ConnectionFactory();
        factory.setHost("192.168.136.128");
        factory.setUsername("admin");
        factory.setPassword("admin");
        /*获取连接*/
        Connection connection = factory.newConnection();
        /*拿到信道*/
        Channel channel = connection.createChannel();
        channel.queueDeclareNoWait(QUEUE_NAME,false,false,false,null);
        /**/
        channel.basicPublish("",QUEUE_NAME,null,"hello..world".getBytes());
        System.out.println("消息发送完毕");
    }
}
